<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:include page="/views/include.jsp"></jsp:include>
<script type="text/javascript">
        	var contextPath = '<%=request.getContextPath()%>';
        	$.parser.onComplete = function(){
            	$('body').css('visibility','visible');
            	setTimeout(function(){
	            	$('#loading-mask').remove();
            	},50);
        	};
        	$(function(){
            	$(window).resize(function(){
                	$('#mainlayout').layout('resize');
            	});
            	
            	$('#t-shopInfo').datagrid({onDblClickRow:function dblClickRow(rowIndex,rowData){
    				$('#myform').formid('loadit',rowData);
    				$.each($('#myform input'),function(i){
    					$(this).attr("readonly","true");
    				});
    				$("#dlg-buttons a::first-child").hide();
    				$('#dlg').dialog('setTitle','查看shopInfo信息').dialog('open');
    			}});
        	});
        </script>
<style type="text/css">
.e-input {
	width: 198px;
	border: 1px solid #A4BED4;
	height: 18px;
	line-height: 18px;
}
</style>
<script type="text/javascript">
//----------------------------------------------用来格式化显示状态
var status1;
$.getJSON("<c:url value='/permissions/outDicJsonByNicknameActions.tg?nickName=status'/>", function(json){
	status1=json;
});
function statusFormatter(value){
	for(var i=0; i<status1.length; i++){		
		if (status1[i].value == value) return status1[i].name;
	}
	return value;
}

//---------------------------------------------------------------------

		var actionUrl;
		function newItem(){
			$('#myform').form('clear');
			$.each($('#myform input'),function(i){
				$(this).removeAttr("readonly");
			});
			$("#dlg-buttons a::first-child").show();
			
			//$('#parentId').combotree({
			//	url:'<c:url value="/permissions/getTreeGroup.tg"/>',
			//	valueField:'id',
			//	textField:'text'				
			//});
			
			
			$('#dlg').dialog('setTitle', '填写ShopInfo资料').dialog('open');
			actionUrl = '<c:url value="/permissions/saveShopInfo.tg"/>';
		}
		function saveItem(){
				
			$('#myform').form('submit', {
				url:actionUrl,
				onSubmit: function(){
					return $('#myform').form('validate');
				},
				success: function(data){
					$('#dlg').dialog('close');
					$('#t-shopInfo').datagrid('reload');
					data=eval('('+data+')');
					if(data.success){
						$.messager.show(
							{
								title:'提示',
								msg:'操作成功！',
								showType:'slide'
							}
						);
					}
					if(data.error){
						$.messager.alert('提示','操作失败！','error');
					}
				}
			});
		}
		
		function editItem(){
			$('#myform').form('clear');
			var row = $('#t-shopInfo').datagrid('getSelected');
			if (row){				
				$('#cid').val(row.id);

				actionUrl = '<c:url value="/permissions/findShopInfo.tg"/>'; 
				$('#myform').formid('loadit',row);
				
				$('#shopInfoform').form('submit', {
					url:actionUrl,
					onSubmit: function(){
						return true;
					},
					success: function(data){
						data=eval('('+data+')');
						var tempObj = data.rows[0];				
					}
				});
				
				$('#dlg').dialog('setTitle', '修改shopInfo资料').dialog('open');
				$.each($('#myform input'),function(i){
					$(this).removeAttr("readonly");
				});
				$("#dlg-buttons a::first-child").show();
				actionUrl = '<c:url value="/permissions/updateShopInfo.tg"/>';
			}else{
				alert('请选择ShopInfo修改');
			}
		}
		function delItem(){
			var row = $('#t-shopInfo').datagrid('getSelected');
			if(row){
				if(confirm('确认要删除ShopInfo?'))
				{	
					$('#cid').val(row.id);
					actionUrl = '<c:url value="/permissions/delShopInfo.tg"/>';
					$('#shopInfoform').form('submit', {
						url:actionUrl,
						success: function(data){
							$('#dlg').dialog('close');
							$('#t-shopInfo').datagrid('reload');
							data=eval('('+data+')');
							if(data.success){
								$.messager.show(
									{
										title:'提示',
										msg:'操作成功！',
										showType:'slide'
									}
								);
							}
							if(data.error){
								$.messager.alert('提示','操作失败！','error');
							}
						}
					});
				}
			}else{
				alert('请选择要删除的shopInfo！谢谢'); 
			}
		}
		
		function searchRecord(){			
			var param = {};
			//param['user.logonid'] = $('#qloginid').val();			
			$('#t-shopInfo').datagrid("load",param);
			//$('#t-users').datagrid('options').url = url;
		}
 </script>